const http=require('http');
const { default: test } = require('node:test');

const server=http.createServer((request,response)=>{
//1.设置响应状态码
    // response.statusCode=404;
    // response.statusCode=200;
//2.设置响应状态描述(极少用,一般与状态码对应)
    // response.statusMessage='hello http'
//3.设置响应头
    response.setHeader('content-type','text/html;charset=utf-8');
    response.setHeader('myHeader','test');
    response.setHeader('test',['a','b','c']);//设置为一个响应头多个值
//4.设置响应体
//write 可多次调用
    response.write('hello');
    response.write('hello');
    response.write('hello');
    response.write('hello');
    //一般只设置write或者end
    response.end();
    //响应体end只能设置一次
});

server.listen(8000,()=>{
    console.log('服务启动成功');
});